package com.liug.droidsmall2.adapter;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.liug.droidsmall2.R;
import com.liug.droidsmall2.entities.HomeData;
import com.liug.droidsmall2.fragment.RecruitFragment;

import java.util.ArrayList;
import java.util.List;
/**
 * Created by LG on 2018/7/31.
 */
public class RecruitAdapter extends RecyclerView.Adapter {
    private static final int HEAD = 1;
    private static final int CONTENTQ = 2;
    List<HomeData.DataBean.GuanggaoBean> guanggao;
    Context context;
    private ArrayList<String> list_path;
    private ArrayList<String> list_title;
    RecruitFragment fragment;
    public  Bundle savedInstanceState;
    public RecruitAdapter(List<HomeData.DataBean.GuanggaoBean> guanggao, Context context, RecruitFragment fragment,Bundle savedInstanceState) {
        this.context = context;
        this.guanggao = guanggao;
        this.fragment = fragment;
        this.savedInstanceState=savedInstanceState;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate;
        if (HEAD == viewType) {
            inflate = View.inflate(context, R.layout.recruit_fragment_header, null);
//            inflate = View.inflate(context, R.layout.home_adapter_item, null);
            return new HeadHolder(inflate);
        } else {
            inflate = View.inflate(context, R.layout.home_adapter_item, null);
            return new Holder(inflate);
        }
    }

    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return HEAD;
        } else {
            return CONTENTQ;
        }
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        int itemViewType = getItemViewType(position);

    }

    @Override
    public int getItemCount() {
        return guanggao.size();
//        return 3;
    }

    class Holder extends RecyclerView.ViewHolder {

        private final ImageView img;
        private final TextView name;
        private final TextView add_time;
        private final LinearLayout item_listen;

        public Holder(View itemView) {
            super(itemView);
            img = (ImageView) itemView.findViewById(R.id.img);
            name = (TextView) itemView.findViewById(R.id.name);
            add_time = (TextView) itemView.findViewById(R.id.add_time);
            item_listen = (LinearLayout) itemView.findViewById(R.id.item_listen);
        }
    }

    class HeadHolder extends RecyclerView.ViewHolder {

        public HeadHolder(View itemView) {
            super(itemView);
            MapView mapView = (MapView)itemView. findViewById(R.id.mapview);
            mapView.onCreate(savedInstanceState);
            AMap aMap = mapView.getMap();
            aMap.setTrafficEnabled(true);// 显示实时交通状况
            //地图模式可选类型：MAP_TYPE_NORMAL,MAP_TYPE_SATELLITE,MAP_TYPE_NIGHT
            aMap.setMapType(AMap.MAP_TYPE_NORMAL);// 卫星地图模式
        }
    }

}
